import { HTTP_INTERCEPTORS } from '@angular/common/http';
import { NgModule, Optional, SkipSelf } from '@angular/core';

import { DefaultHttpInterceptor } from './base/default-http.interceptor';
import { throwIfAlreadyLoaded } from './module-import-guard';

const INTERCEPTORS = [
  {
    provide: HTTP_INTERCEPTORS,
    useClass: DefaultHttpInterceptor,
    multi: true
  }
];
@NgModule({
  providers: [...INTERCEPTORS]
})
export class CoreModule {
  constructor(@Optional() @SkipSelf() parentModule: CoreModule) {
    if (parentModule) {
      throwIfAlreadyLoaded(parentModule, 'CoreModule');
    }
  }
}
